package euler;

import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.Test;

public class ProblemAsTC {
	
	boolean includeSlow=false;
	

	@Test
	public void problem_001() {
		assertTrue(Problems.solveMultiplesOf3And5()==233168);
	}
	
	@Test
	public void problem_002() {
		assertTrue(Problems.evenFibonacciNumbers()==4613732);
	}
	
	@Test
	public void problem_003() {		
		assertTrue(Problems.largestPrimeFactor(Long.parseLong("600851475143"))==6857);
	}
	
	@Test
	public void problem_004() {
		assertTrue(Problems.largestPalindrome()==906609);
	}
	
	@Test	
	public void problem_005() {
		if (includeSlow)
		assertTrue(Problems.divisibleBy(1,20)==232792560);		
	}
	
	@Test
	public void problem_006() {		
		assertTrue(Problems.squareOfSums(100)==25164150);		
	}
	
	@Test
	public void problem_007() {
		assertTrue(Problems.calcNthPrimeNumber(10001)==104743);		
	}
	
	@Test
	public void problem_008() {
		assertTrue(Problems.largestProduct()==40824);
	}
	
	@Test
	public void problem_009() {
		assertTrue(Problems.findTriplet()==31875000);
	}
	
	@Test
	public void problem_010() {	    
		assertTrue(Problems.sumArr(Problems.calcPrimelist(2000000,-1))==Long.parseLong("142913828922"));
	}
	
	@Test
	public void problem_026() {
		assertTrue(Problems.findWiederholung(Problems.largeUnitFraction(7)).equalsIgnoreCase("142857"));
		int maxLength=0;
		int maxDivisor=1;	
		String maxSequence="";
		for (int i=1;i<1000;i++) {
			String recurSeq=Problems.findWiederholung(Problems.largeUnitFraction(i));
			if (recurSeq.length()>maxLength) {
				maxLength=recurSeq.length();
				maxDivisor=i;
				maxSequence=recurSeq;
			}
		}
		System.out.println("maxSequence="+maxSequence+"\n maxDivisor="+maxDivisor);
	}
	
	@Test
	public void problem_031() {
		ArrayList<Integer> coinsize = new ArrayList<Integer>();
		coinsize.add(1);coinsize.add(2);coinsize.add(5);coinsize.add(10);
		coinsize.add(20);coinsize.add(50);coinsize.add(100);coinsize.add(200);
		//System.out.println(Problems.numberOfCoinVariations(coinsize, 200, 200));
		System.out.println(Problems.numberOfCoinVariations(coinsize, 200, 2));
	}
	
	@Test
	public void problem_421() {
		long testZerlegung1=2*2*2*2*2 *2*2*2*2*2 *2*2*2*2*2 +1;
		long testZerlegung2=Long.parseLong("1000000000000000")+1;
		assertTrue(Problems.sumArr(Problems.distinctPrimefactorsNotExceedingM(testZerlegung1,10))==3);
		assertTrue(Problems.sumArr(Problems.distinctPrimefactorsNotExceedingM(testZerlegung1,1000))==345);
		assertTrue(Problems.sumArr(Problems.distinctPrimefactorsNotExceedingM(testZerlegung2,1000))==483);		
	}
	
	@Test
	public void problem_421_primfaktoren() {
		long testZerlegung1=2*2*2*2*2 *2*2*2*2*2 *2*2*2*2*2 +1;
		long testZerlegung2=Long.parseLong("1000000000000000")+1;
		//long primeLimit=Long.parseLong("20000000");
		//ArrayList<Long> primes =Problems.calcPrimelist(primeLimit, -1);
		//System.out.println("primelist calculated limit="+primeLimit+" size="+primes.size());
		//Problems.createTestArrayList(25706070);
		assertTrue(Problems.sumArr(Problems.distinctPrimefactorsNotExceedingM(testZerlegung1,10))==3);
		assertTrue(Problems.sumArr(Problems.distinctPrimefactorsNotExceedingM(testZerlegung1,1000))==345);
		assertTrue(Problems.sumArr(Problems.distinctPrimefactorsNotExceedingM(testZerlegung2,1000))==483);		
	}

	
	
}
